﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class PlanarBatteryWayWcsActionBO
    {
        /// <summary>
        /// 设备号
        /// </summary>
        public string EquipmentCode { get; set; }
        /// <summary>
        /// 任务号
        /// </summary>
        public int TaskCode { get; set; }
        /// <summary>
        /// 目标设备号
        /// </summary>
        public int ToEquipmentCode { get; set; }
        /// <summary>
        /// 托盘码
        /// </summary>
        public string PalletBarcode { get; set; }
        /// <summary>
        /// 握手类型
        /// </summary>
        public short ActionType { get; set; }
        /// <summary>
        /// 托盘类型
        /// </summary>
        public byte PalletType { get; set; }
        /// <summary>
        /// 报警代码
        /// </summary>
        public byte AlrmCode { get; set; }

        /// <summary>
        /// 单机任务标识
        /// </summary>
        public byte Reserve { get; set; }
        /// <summary>
        /// 预留2
        /// </summary>
        public byte Reserve2 { get; set; }
        /// <summary>
        /// 预留3
        /// </summary>
        public byte Reserve3 { get; set; }
        /// <summary>
        /// 预留4
        /// </summary>
        public byte Reserve4 { get; set; }
        /// <summary>
        /// 1号电芯条码
        /// </summary>
        public string BatteryCode1 { get; set; }
        /// <summary>
        /// 1号电芯结果
        /// </summary>
        public byte BatteryFlag1 { get; set; }
        /// <summary>
        /// 2号电芯条码
        /// </summary>
        public string BatteryCode2 { get; set; }
        /// <summary>
        /// 2号电芯结果
        /// </summary>
        public byte BatteryFlag2 { get; set; }

        public void Serialize(byte[] bytes)
        {


            EquipmentCode = HelperByte.GetDIntAt(bytes, 0).ToString();
            TaskCode = HelperByte.GetDIntAt(bytes, 4);
            ToEquipmentCode = HelperByte.GetDIntAt(bytes, 8);
            int length = HelperByte.GetSIntAt(bytes, 13);
            PalletBarcode = HelperByte.GetCharsAt(bytes, 14, length);
            ActionType = HelperByte.GetIntAt(bytes, 32);
            PalletType = HelperByte.GetByteAt(bytes, 34);
            AlrmCode = HelperByte.GetByteAt(bytes, 35);
            Reserve = HelperByte.GetByteAt(bytes, 36);//单机任务标志
            Reserve2 = HelperByte.GetByteAt(bytes, 37);
            Reserve3 = HelperByte.GetByteAt(bytes, 38);
            Reserve4 = HelperByte.GetByteAt(bytes, 39);

            int length1 = HelperByte.GetSIntAt(bytes, 41);
            BatteryCode1 = HelperByte.GetCharsAt(bytes, 42, length1);
            BatteryFlag1 = HelperByte.GetByteAt(bytes, 71);
            int length2 = HelperByte.GetSIntAt(bytes, 73);
            BatteryCode2 = HelperByte.GetCharsAt(bytes, 74, length2);
            BatteryFlag2 = HelperByte.GetByteAt(bytes, 102);

        }
    }
}
